#!/usr/bin/env python
# coding=utf-8
"""
同步redis
从redisIn同步到redisOut

安装:
python
python-pip
easy-install redis
"""

import redis
import time

redisIn =  redis.StrictRedis(host='192.168.1.36', port=6379)
redisOut =  redis.StrictRedis(host='localhost', port=6379,  password='Jsecode123')

def sync():
    keys = redisIn.keys('RescueVeh:CurGps:*')

    # put to another
    for key in keys:
        print(key)
        redisOut.hmset(key, redisIn.hgetall(key))

if __name__ == '__main__':
    while True:
        sync()
        print("sync data at ",  time.strftime("%Y-%m-%d %X", time.localtime() ))
        time.sleep(30) # sleep 30s


